package net.borlis.sample.services.facade.ws.response;

import net.borlis.dictionaries.product.SaleType;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author alex@borlis.net on 05.06.2014.
 */
@XmlRootElement
public class ProviderWithVitoResponse extends ProviderResponse {

    @XmlElement
    private Boolean enabled;

    @XmlElement
    private SaleType saleType;

    public ProviderWithVitoResponse() {
        super();
    }

    public ProviderWithVitoResponse(Long id, String code, String name, Boolean enabled, SaleType saleType) {
        super(id, code, name);
        this.enabled = enabled;
        this.saleType = saleType;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public SaleType getSaleType() {
        return saleType;
    }

    @Override
    public boolean equals(Object obj) {
        if (! super.equals(obj)) {
            return false;
        }
        if (obj instanceof ProviderWithVitoResponse) {
            ProviderWithVitoResponse other = (ProviderWithVitoResponse) obj;
            EqualsBuilder builder = new EqualsBuilder();
            builder.append(getSaleType(), other.getSaleType());
            return builder.isEquals();
        }
        return false;
    }

    @Override
    public int hashCode() {
        HashCodeBuilder builder = new HashCodeBuilder();
        builder.append(getId());
        builder.append(getCode());
        builder.append(getName());
        builder.append(getSaleType());
        return builder.toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).
                append("id", getId()).
                append("code", getCode()).
                append("name", getName()).
                append("enabled", getEnabled()).
                append("saleType", getSaleType()).
                toString();
    }

}
